//
//  MJRunningCarHeader.m
//  CarLifes
//
//  Created by yu on 2017/8/22.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "MJRunningCarHeader.h"

@implementation MJRunningCarHeader

#pragma mark - 重写方法
#pragma mark 基本设置
- (void)prepare
{
    [super prepare];
    
    // 设置普通状态的动画图片
    NSMutableArray *idleImages = [NSMutableArray array];
    for (NSUInteger i = 1; i <= 15; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"loading_%zd", i]];
        [idleImages addObject:image];
    }
    [self setImages:idleImages forState:MJRefreshStateIdle];
    
    // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<= 3; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"loading_%zd", i]];
        [refreshingImages addObject:image];
    }
    [self setImages:refreshingImages forState:MJRefreshStatePulling];
    
    // 设置正在刷新状态的动画图片
    [self setImages:refreshingImages forState:MJRefreshStateRefreshing];
    
    self.mj_h = 55;
}

- (void)placeSubviews
{
    [super placeSubviews];
    
//    self.gifView.backgroundColor = [UIColor blueColor];
    self.gifView.frame = CGRectMake(kScreenWidth*0.15, 5, 100, 60);
    self.gifView.contentMode = UIViewContentModeScaleAspectFit;
    //
//    self.stateLabel.backgroundColor = [UIColor yellowColor];
    self.stateLabel.textAlignment = NSTextAlignmentLeft;
    self.stateLabel.frame = CGRectMake(CGRectGetMaxX(self.gifView.frame), 5, kScreenWidth - CGRectGetMaxX(self.gifView.frame), 30);
    //
//    self.lastUpdatedTimeLabel.backgroundColor = [UIColor redColor];
    self.lastUpdatedTimeLabel.font = SYSTEM_FONT(13);
    self.lastUpdatedTimeLabel.textAlignment = NSTextAlignmentLeft;
    self.lastUpdatedTimeLabel.frame = CGRectMake(CGRectGetMinX(self.stateLabel.frame), CGRectGetMaxY(self.stateLabel.frame), CGRectGetWidth(self.stateLabel.frame), 15);
}

@end

@implementation MJCustomHeader

@end
